﻿/// <reference path="../jquery.min.js" />
/// <reference path="../rsseasy.min.js" />

//初始化日期选择框

var dateselectbox = {
    "box": $("#dateselectbox"),
    "yearbox": null,
    "monthbox": null,
    "daybox": null,
    "curkey": null,
    init: function (min, max) {
        this.yearbox = this.box.find("[selectyear]");
        this.monthbox = this.box.find("[selectmonth]");
        this.daybox = this.box.find("[selectday]");

        var html = "", min = min || new Date().getFullYear(), max = max || (min + 30);
        for (var i = min; i < max; i++) {
            html += '<li item="' + i + '">' + i + '</li>';
        }
        this.yearbox.find("ul").first().html(html);

        html = '';
        for (i = 1; i < 13; i++) {
            html += '<li item="' + (i < 10 ? "0" + i : i) + '">' + (i < 10 ? "0" + i : i) + '</li>';
        }
        this.monthbox.html(html);

        html = '';
        for (i = 1; i < 31; i++) {
            html += '<li item="' + (i < 10 ? "0" + i : i) + '">' + (i < 10 ? "0" + i : i) + '</li>';
        }
        this.daybox.html(html);

        this.box.find(".right").click(function () {
            dateselectbox.close();
        });
    },
    "show": function (key) {
        this.box.show();
        this.curkey = key;
        this[key] = function () { }
        return this;
    },
    "close": function () {
        this.curkey();
        this.box.hide();
    },
    "selectslide": function () {
        this.box.find("[selectslide]").unbind().selectcascade().on("selectslideend", function (ev, data) {
            console.info("json", data);
        });
    }
};